package com.deepface.system.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.deepface.common.utils.DateUtils;
import com.deepface.common.utils.SecurityUtils;
import com.deepface.system.domain.SysFaceJob;
import com.deepface.system.service.SysFaceJobService;
import com.deepface.system.mapper.SysFaceJobMapper;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * @author 74707
 * @description 针对表【sys_face_job(换脸任务表)】的数据库操作Service实现
 * @createDate 2023-12-19 21:02:22
 */
@Service
public class SysFaceJobServiceImpl extends ServiceImpl<SysFaceJobMapper, SysFaceJob>
    implements SysFaceJobService {

  @Resource
  SysFaceJobMapper sysFaceJobMapper;

  public int insertSysFaceJob(SysFaceJob sysFaceJob) {
    Long id = SecurityUtils.getUserId();
    String name = SecurityUtils.getUsername();
    sysFaceJob.setUserId(id);
    sysFaceJob.setCreateBy(name);
    sysFaceJob.setCreateTime(DateUtils.getNowDate());
    return sysFaceJobMapper.insert(sysFaceJob);
  }

  @Override
  public int updateSysFaceJob(SysFaceJob sysFaceJob) {
    String name = SecurityUtils.getUsername();
    sysFaceJob.setUpdateBy(name);
    sysFaceJob.setUpdateTime(DateUtils.getNowDate());
    System.out.println(sysFaceJob.getJobId());
    return sysFaceJobMapper.update(sysFaceJob,
        Wrappers.<SysFaceJob>lambdaUpdate().eq(SysFaceJob::getJobId, sysFaceJob.getJobId())
            .eq(SysFaceJob::getDelFlag, "0"));
  }
}